import tensorflow as tf
from tensorflow.keras import layers, models

# 构建生成器
generator = models.Sequential([
    layers.Dense(128, activation='relu', input_dim=100),
    layers.Dense(784, activation='tanh')
])

# 构建判别器
discriminator = models.Sequential([
    layers.Dense(128, activation='relu', input_dim=784),
    layers.Dense(1, activation='sigmoid')
])

# 构建GAN模型
gan = models.Sequential([generator, discriminator])
gan.compile(optimizer='adam', loss='binary_crossentropy')